package de.upb.aquarium;

import javax.media.opengl.GL;

import de.upb.aquarium.api.objects.AnimatedObject;
import de.upb.aquarium.api.objects.ComposedObject;
import de.upb.aquarium.api.objects.General3DObject;
import de.upb.aquarium.api.objects.MovingObject;
import de.upb.aquarium.api.objects.PathCalculator;
import de.upb.aquarium.api.objects.StaticObject;
import de.upb.aquarium.api.objects.TransparentObject;
import de.upb.aquarium.api.utility.VectorFloat;

public class Aquarium extends ComposedObject {

	final boolean ANIMATIONS_ENABLED = true;

	StaticObject aquariumFrame;
	TransparentObject[] aquariumGlass = new TransparentObject[5];
	StaticObject aquariumGround;
	AnimatedObject fish;

	Aquarium(GL gl){
		gl.glDisable(GL.GL_CULL_FACE);

		getContainedObjects().add(new StaticObject(gl, "models/aquarium/aquarium_frame_0.obj", 1));
		for (int i=1;i<5;i++)
			getContainedObjects().add(new TransparentObject(gl, "models/aquarium/aquarium_frame_"+i+".obj", 1));

		for (int i=0;i<5;i+=1) {
			aquariumGlass[i] = new TransparentObject(gl, "models/aquarium/aquarium_wall_"+i+".obj", 1);
			getContainedObjects().add(aquariumGlass[i]);
		}

		aquariumGround = new StaticObject(gl, "models/aquarium/aquarium_ground2.obj", 1);
		getContainedObjects().add(aquariumGround);

		getContainedObjects().add(new StaticObject(gl, "models/ship/ship2.obj", 1));

		General3DObject fish1;
		if (ANIMATIONS_ENABLED)
			fish1 = new AnimatedObject(gl, "models/labidochromis_caeruleus_anim/labidochromis_caeruleus_anim_%X.obj", 0.05f);
		else
			fish1 = new StaticObject(gl, "models/labidochromis_caeruleus/labidochromis_caeruleus.obj", 0.05f);
		//fish1.setRotation(90,180,0);
		//fish1.setPosition(5.0f,4.8f,-6.5f);
		//getContainedObjects().add(fish1);
		VectorFloat[] points1 = new VectorFloat[35];
		points1[0] = new VectorFloat(new float[] {5.488f, 4.24f,-5.87f});
		points1[1] = new VectorFloat(new float[] {5.669f, 4.189f, -5.852f});
		points1[2] = new VectorFloat(new float[] {5.786f, 4.165f, -5.823f});
		points1[3] = new VectorFloat(new float[] {5.937f, 4.145f, -5.765f});
		points1[4] = new VectorFloat(new float[] {6.03f, 4.15f, -5.655f});
		points1[5] = new VectorFloat(new float[] {6.088f, 4.16f, -5.481f});
		points1[6] = new VectorFloat(new float[] {6.082f, 4.155f, -5.289f});
		points1[7] = new VectorFloat(new float[] {6.042f, 4.145f, -5.098f});
		points1[8] = new VectorFloat(new float[] {5.937f, 4.155f, -4.964f});
		points1[9] = new VectorFloat(new float[] {5.757f, 4.169f, -4.912f});
		points1[10] = new VectorFloat(new float[] {5.583f, 4.193f, -4.848f});
		points1[11] = new VectorFloat(new float[] {5.438f, 4.213f, -4.744f});
		points1[12] = new VectorFloat(new float[] {5.288f, 4.237f, -4.688f});
		points1[13] = new VectorFloat(new float[] {5.09f, 4.28f, -4.692f});
		points1[14] = new VectorFloat(new float[] {4.956f, 4.318f, -4.808f});
		points1[15] = new VectorFloat(new float[] {4.933f, 4.328f, -4.964f});
		points1[16] = new VectorFloat(new float[] {4.985f, 4.338f, -5.144f});
		points1[17] = new VectorFloat(new float[] {5.148f, 4.347f, -5.313f});
		points1[18] = new VectorFloat(new float[] {5.363f, 4.371f, -5.481f});
		points1[19] = new VectorFloat(new float[] {5.525f, 4.4f, -5.667f});
		points1[20] = new VectorFloat(new float[] {5.595f, 4.41f, -5.841f});
		points1[21] = new VectorFloat(new float[] {5.647f, 4.434f, -6.032f});
		points1[22] = new VectorFloat(new float[] {5.751f, 4.448f, -6.235f});
		points1[23] = new VectorFloat(new float[] {5.926f, 4.424f, -6.346f});
		points1[24] = new VectorFloat(new float[] {6.013f, 4.4f, -6.497f});
		points1[25] = new VectorFloat(new float[] {6.001f, 4.395f, -6.694f});
		points1[26] = new VectorFloat(new float[] {5.897f, 4.386f, -6.851f});
		points1[27] = new VectorFloat(new float[] {5.699f, 4.376f, -6.92f});
		points1[28] = new VectorFloat(new float[] {5.514f, 4.362f, -6.909f});
		points1[29] = new VectorFloat(new float[] {5.328f, 4.342f, -6.833f});
		points1[30] = new VectorFloat(new float[] {5.235f, 4.328f, -6.682f});
		points1[31] = new VectorFloat(new float[] {5.2f, 4.304f, -6.502f});
		points1[32] = new VectorFloat(new float[] {5.235f, 4.29f, -6.305f});
		points1[33] = new VectorFloat(new float[] {5.281f, 4.27f, -6.131f});
		points1[34] = new VectorFloat(new float[] {5.357f, 4.266f, -5.986f});

		PathCalculator pc1 = new PathCalculator(points1, 0.005f);

		MovingObject mfish1 = new MovingObject(fish1, pc1);
		getContainedObjects().add(mfish1);

		General3DObject fish2;
		if (ANIMATIONS_ENABLED)
			fish2 = new AnimatedObject(gl, "models/fundulopanchax_anim/fundulopanchax_anim_%X.obj", 0.03f);
		else
			fish2 = new StaticObject(gl, "models/fundulopanchax/fundulopanchax.obj", 0.03f);
		//fish2.setRotation(90,-30,0);
		//fish2.setPosition(4.5f, 4.0f, -4.0f);
		//getContainedObjects().add(fish2);

		VectorFloat[] points = new VectorFloat[16];
		points[0] = new VectorFloat(new float[] {6.160f,4.101f,-6.451f});
		points[1] = new VectorFloat(new float[] {6.404f,4.149f,-5.77f});
		points[2] = new VectorFloat(new float[] {6.452f,4.324f,-4.882f});
		points[3] = new VectorFloat(new float[] {6.368f,4.42f,-4.512f});
		points[4] = new VectorFloat(new float[] {6.005f,4.372f,-4.303f});
		points[5] = new VectorFloat(new float[] {5.48f,4.308f,-4.333f});
		points[6] = new VectorFloat(new float[] {4.925f,4.276f,-4.518f});
		points[7] = new VectorFloat(new float[] {4.764f,4.149f,-5.013f});
		points[8] = new VectorFloat(new float[] {4.955f,4.053f,-5.729f});
		points[9] = new VectorFloat(new float[] {5.014f,4.149f,-6.081f});
		points[10] = new VectorFloat(new float[] {4.973f,4.18f,-6.57f});
		points[11] = new VectorFloat(new float[] {4.841f,4.098f,-6.999f});
		points[12] = new VectorFloat(new float[] {4.961f,4.021f,-7.333f});
		points[13] = new VectorFloat(new float[] {5.271f,4.085f,-7.435f});
		points[14] = new VectorFloat(new float[] {5.676f,4.101f,-7.387f});
		points[15] = new VectorFloat(new float[] {6.022f,4.101f,-6.958f});

		PathCalculator pc = new PathCalculator(points, 0.005f);

		MovingObject mfish2 = new MovingObject(fish2, pc);
		getContainedObjects().add(mfish2);

		//		StaticObject treasure = new StaticObject(gl, "models/treasure.obj", 1);
		//		treasure.setPosition(1,1,-1);
		//		getContainedObjects().add(treasure);
	}
}
